// pages/user/user.js

const app = getApp();


Page({

  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    number: '请输入手机号',
    nickname: "",
    image: "",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 我的收藏
   */
  navigateToHistory: function () {
    wx.navigateTo({
      url: '../history/history'
    });
  },


  /**
   * 跳转到手机号码
   */
  navigrateMobile: function () {
    let source = "user"
    wx.navigateTo({
      url: '../myNumber/myNumber?source=' + source,
    });
  },





  /**
   * 跳转到意见反馈
   */
  navigateToFeedback: function () {
    wx.navigateTo({
      url: '../feedback/feedback',
      success: function (res) {},
      fail: function (res) {},
      complete: function (res) {},
    });
  },


  /**
   * 跳转到关于我们
   */
  navigateToAbout: function () {
    wx.navigateTo({
      url: '../about/about',
      success: function (res) {},
      fail: function (res) {},
      complete: function (res) {},
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    let that = this;
    let number = wx.getStorageSync('number')
    that.setData({
      number: number
    })
    let userInfo = wx.getStorageSync('userInfo')
    this.setData({
      image: userInfo["avatar"],
      nickname: userInfo["nickname"]
    })

  },

  onPullDownRefresh(){
    let that =this;
    that.onShow();
  },

  logout: function () {
    wx.clearStorage({
      success: (res) => {
        wx.showToast({
          title: '退出成功',
        })
        wx.reLaunch({
          url: '../../pages/index/index',
        })
      },
    })
  }

})